package com.bestvike.stone.core.util.area;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.Collection;

/**
 * 省级行政区
 * Created by 许崇雷 on 2018-07-28.
 */
@Data
@EqualsAndHashCode(exclude = "cityCollection")
@ToString(exclude = "cityCollection")
public final class Province implements IArea {
    @JSONField(ordinal = 1)
    private final String code;
    @JSONField(ordinal = 2)
    private final String name;
    @JSONField(ordinal = 3)
    private final Collection<City> cityCollection = new CityCollection(this);

    public Province(String code, String name, Collection<City> cityCollection) {
        this.code = code;
        this.name = name;
        if (cityCollection != null)
            this.cityCollection.addAll(cityCollection);
    }

    public CityCollection getCityCollection() {
        return (CityCollection) this.cityCollection;
    }
}
